package com.lanou.tipsy.adapter.search;

import android.content.Context;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.TextView;

import com.lanou.tipsy.R;
import com.lanou.tipsy.entity.search.hot.HotSearchResultEntity;
import com.lanou.tipsy.fragment.search.SearchFragment;

import java.util.ArrayList;

/**
 * Created by wangshuai on 15/11/7.
 */
public class HotSearchAdapter extends BaseAdapter {
    //上下文
    private Context mContext;
    //数据接受
    private ArrayList<HotSearchResultEntity> data;
    //构造方法
    public HotSearchAdapter(Context mContext, ArrayList<HotSearchResultEntity> data) {
        this.mContext = mContext;
        this.data = data;

    }

    @Override
    public int getCount() {
        return data != null && data.size() > 0 ? data.size() : 0;
    }

    @Override
    public HotSearchResultEntity getItem(int position) {
        return data != null && data.size() > 0 ? data.get(position) : null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;

        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.gridview_search_hot, null);
            holder = new ViewHolder();
            holder.hotSearchTv = (TextView) convertView.findViewById(R.id.hotSearchTv);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        HotSearchResultEntity hs = getItem(position);
        if (hs != null) {

            holder.hotSearchTv.setText(hs.getWord());

        }
        return convertView;
    }

    private class ViewHolder {
        private TextView hotSearchTv;


    }
}
